package com.ygj.dept.action;

import static com.base.common.GlobaConstants.ACTION_RESULT_DATA;
import static com.base.common.GlobaConstants.ASYNCHRONOUS;
import static com.base.common.GlobaConstants.CONTENT_TYPE;
import static com.base.common.GlobaConstants.CONTENT_TYPE_JSON;
import static com.base.common.GlobaConstants.JSON;
import static com.base.common.GlobaConstants.ROOT;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.base.common.action.AbstractBaseAction;
import com.base.common.bean.ActionResult;
import com.cjy.common.bean.OpAttributes;
import com.ygj.dept.service.DeptService;

/**
 * 部门action
 * 
 * @author Kevin Colin
 * @datetime 2015年9月15日下午5:01:29
 *
 */
@Action("deptAction")
@Results({ @Result(name = ASYNCHRONOUS, type = JSON, params = { ROOT,
		ACTION_RESULT_DATA, CONTENT_TYPE, CONTENT_TYPE_JSON }) })
public class DeptAction extends AbstractBaseAction {

	private static final long serialVersionUID = 1L;

	@Resource
	private DeptService deptService;
	
	private int compoundsId;

	public int getCompoundsId() {
		return compoundsId;
	}

	public void setCompoundsId(int compoundsId) {
		this.compoundsId = compoundsId;
	}

	/**
	 * 获取所有部门类别
	 * 
	 * @return
	 */
	public String getAllDepts() {
		try {
			actionResult = ActionResult.getActionResult(new OpAttributes().add(
					"code", 1).add("result", deptService.queryAllDepts(compoundsId)));
		} catch (Exception e) {
			e.printStackTrace();
			actionResult = ActionResult.getActionResult(new OpAttributes().add(
					"code", 0));
		}
		return returnType();
	}
}
